﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<QuizAppMvc2.Models.NewQuestionModels>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Create2
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <h2>
        Create2</h2>
    <% using (Html.BeginForm())
       {%>
    <%: Html.ValidationSummary(true) %>
    <fieldset>
        <legend>Fields</legend>
        <%: Html.DropDownListFor(model => model.materiaid, new SelectList(Model.materias, "idmateria", "nome"), "Selecione a materia")%>
        <%: Html.DropDownListFor(model => model.topicoid, Enumerable.Empty<SelectListItem>(), "Selecione o tópico ") %>
        <%: Html.DropDownListFor(model => model.subtopico, Enumerable.Empty<SelectListItem>(), "Selecione o subtópico ")%>
        <div class="editor-label">
            <%: Html.LabelFor(model => model.texto) %>
        </div>
        <div class="editor-field">
            <%: Html.TextBoxFor(model => model.texto) %>
            <%: Html.ValidationMessageFor(model => model.texto) %>
        </div>
        <div class="editor-label">
            <%: Html.LabelFor(model => model.gabarito) %>
        </div>
        <div class="editor-field">
            <%: Html.DropDownListFor(model => model.gabarito , new SelectList( Model.gabaritos, "id", "descricao")) %>
            <%: Html.ValidationMessageFor(model => model.gabarito) %>
        </div>
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
    <% } %>
    <div>
        <%: Html.ActionLink("Back to List", "Index") %>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#materiaid").change(function () {
                var url = '<%= Url.Content("~/") %>' + "Questao/abc";
                var ddlsource = "#materiaid";
                var ddltarget = "#topicoid";
                $("#subtopico").empty();
                $.getJSON(url, { year: $(ddlsource).val() }, function (data) {
                    $(ddltarget).empty();
                    $(ddltarget).append('<option value="">Selecione o topico</option>');
                    $.each(data, function (index, optionData) {
                        $(ddltarget).append("<option value='" + optionData.value + "'>" + optionData.novo + "</option>");
                    });
                });
            });
        });

        $(document).ready(function () {
            $("#topicoid").change(function () {
                var url = '<%= Url.Content("~/") %>' + "Questao/Subtopicos";
                var ddlsource = "#topicoid";
                var ddltarget = "#subtopico";
                $.getJSON(url, { year: $(ddlsource).val() }, function (data) {
                    $(ddltarget).empty();
                    $(ddltarget).append('<option value="">Selecione o subtopico</option>');
                    $.each(data, function (index, optionData) {
                        $(ddltarget).append("<option value='" + optionData.value + "'>" + optionData.novo + "</option>");
                    });
                    
                });
            });
        });
    
    </script>

</asp:Content>
